import { instance } from '@/utils/request';

const addComment = async (data: any): Promise<ResponseApiDto> => {
  return instance.post('/Comments/Add', data);
};

const addComment2 = async (formData: any): Promise<ResponseApiDto> => {
  return instance.upload('/Comments/Add', formData);
};

const deleteComment = async (id: number): Promise<ResponseApiDto> => {
  return instance.post('/Comments/Delete', { commentId: id });
};

const getCommentPagination = async (
  page: number,
  limit: number,
  goodId: number,
  firstId?: number
): Promise<ResponseApiDto> => {
  return instance.get('/Comments/GetPagination', { page, limit, goodId, firstId });
};

const getCommentPenddingPagination = async (
  page: number,
  limit: number,
  isComment: number
): Promise<ResponseApiDto> => {
  return instance.get('/Comments/GetCommentPenddingPagination', { page, limit, isComment });
};

const getAllCommentsCount = async (gid: number) => {
  return instance.get('/Comments/GetCommentCount', { gid });
};

const getSingleComment = async (gid: number, id: number) => {
  return instance.get('/Comments/GetSingleComment', { gid, id });
};

const getHotComments = async (gid: number, count: number) => {
  return instance.get('/Comments/GetHotComments', { gid, count });
};

export default {
  addComment,
  addComment2,
  deleteComment,
  getCommentPagination,
  getCommentPenddingPagination,
  getAllCommentsCount,
  getSingleComment,
  getHotComments,
};
